using QFramework.Example.Scripts.Event;
using QFramework.Example.Scripts.Model;
using UnityEngine;

namespace QFramework.Example.Scripts.Command
{
    public class KillEnemyCommand : AbstractCommand
    {
        protected override void OnExecute()
        {
            var gameModel = this.GetModel<IGameModel>();

            gameModel.KillCount.Value++;

            if (Random.Range(0, 10) < 3) gameModel.Gold.Value += Random.Range(1, 3);

            this.SendEvent<OnKillEnemyEvent>();

            // 十个全部消灭再显示通关界面
            if (gameModel.KillCount.Value == 10)
                this.SendEvent<GamePassEvent>();
        }
    }
}